package com.desaysv.hicar;

import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

/**
 * @author linzi
 * @date 2023-7-17
 */
public class ActiveLinearLayoutManager extends LinearLayoutManager {
    public ActiveLinearLayoutManager(Context context) {
        super(context);
    }

    public ActiveLinearLayoutManager(Context context, int orientation, boolean reverseLayout) {
        super(context, orientation, reverseLayout);
    }

    public ActiveLinearLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    private static final String TAG = "[ActiveLinearLayoutManag]";



    @SuppressLint("LongLogTag")
    @Override
    public int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler, RecyclerView.State state) {
        int orientation = getOrientation();
        if (orientation == HORIZONTAL) {
            int scrolled = super.scrollHorizontallyBy(dx, recycler, state);
            for (int i = 0; i < getChildCount(); i++) {
                View child = getChildAt(i);
                if (i == 1) {
                    child.setScaleX(1f);
                    child.setScaleY(1f);
                } else {
                    child.setScaleX(0.8f);
                    child.setScaleY(0.8f);
                }
            }
            return scrolled;
        } else {
            return 0;
        }

    }
}
